home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_emacs.idb / usr / freeware / info / emacs-14.z / emacs-14
Encoding:
GNU Info File  |  1998-10-28  |  47.8 KB  |  1,138 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.63 from the
  2. input file emacs.texi.
  3.  
  4. 
  5. File: emacs,  Node: Fortran Autofill,  Next: Fortran Columns,  Prev: Fortran Comments,  Up: Fortran
  6.  
  7. Fortran Auto Fill Mode
  8. ----------------------
  9.  
  10.    Fortran Auto Fill mode is a minor mode which automatically splits
  11. Fortran statements as you insert them when they become too wide.
  12. Splitting a statement involves making continuation lines using
  13. `fortran-continuation-string' (*Note ForIndent Cont::).  This splitting
  14. happens when you type SPC, RET, or TAB, and also in the Fortran
  15. indentation commands.
  16.  
  17.    `M-x fortran-auto-fill-mode' turns Fortran Auto Fill mode on if it
  18. was off, or off if it was on.  This command works the same as `M-x
  19. auto-fill-mode' does for normal Auto Fill mode (*note Filling::.).  A
  20. positive numeric argument turns Fortran Auto Fill mode on, and a
  21. negative argument turns it off.  You can see when Fortran Auto Fill mode
  22. is in effect by the presence of the word `Fill' in the mode line,
  23. inside the parentheses.  Fortran Auto Fill mode is a minor mode, turned
  24. on or off for each buffer individually.  *Note Minor Modes::.
  25.  
  26.    Fortran Auto Fill mode breaks lines at spaces or delimiters when the
  27. lines get longer than the desired width (the value of `fill-column').
  28. The delimiters that Fortran Auto Fill mode may break at are `,', `'',
  29. `+', `-', `/', `*', `=', and `)'.  The line break comes after the
  30. delimiter if the variable `fortran-break-before-delimiters' is `nil'.
  31. Otherwise (and by default), the break comes before the delimiter.
  32.  
  33.    By default, Fortran Auto Fill mode is not enabled.  If you want this
  34. feature turned on permanently, add a hook function to
  35. `fortran-mode-hook' to execute `(fortran-auto-fill-mode 1)'.  *Note
  36. Hooks::.
  37.  
  38. 
  39. File: emacs,  Node: Fortran Columns,  Next: Fortran Abbrev,  Prev: Fortran Autofill,  Up: Fortran
  40.  
  41. Checking Columns in Fortran
  42. ---------------------------
  43.  
  44. `C-c C-r'
  45.      Display a "column ruler" momentarily above the current line
  46.      (`fortran-column-ruler').
  47.  
  48. `C-c C-w'
  49.      Split the current window horizontally temporarily so that it is 72
  50.      columns wide.  This may help you avoid making lines longer than
  51.      the 72 character limit that some fortran compilers impose
  52.      (`fortran-window-create-momentarily').
  53.  
  54.    The command `C-c C-r' (`fortran-column-ruler') shows a column ruler
  55. momentarily above the current line.  The comment ruler is two lines of
  56. text that show you the locations of columns with special significance in
  57. Fortran programs.  Square brackets show the limits of the columns for
  58. line numbers, and curly brackets show the limits of the columns for the
  59. statement body.  Column numbers appear above them.
  60.  
  61.    Note that the column numbers count from zero, as always in GNU Emacs.
  62. As a result, the numbers may be one less than those you are familiar
  63. with; but the positions they indicate in the line are standard for
  64. Fortran.
  65.  
  66.    The text used to display the column ruler depends on the value of
  67. the variable `indent-tabs-mode'.  If `indent-tabs-mode' is `nil', then
  68. the value of the variable `fortran-column-ruler-fixed' is used as the
  69. column ruler.  Otherwise, the variable `fortran-column-ruler-tab' is
  70. displayed.  By changing these variables, you can change the column
  71. ruler display.
  72.  
  73.    For even more help, use `C-c C-w' (`fortran-window-create'), a
  74. command which splits the current window horizontally, making a window 72
  75. columns wide.  By editing in this window you can immediately see when
  76. you make a line too wide to be correct Fortran.
  77.  
  78. 
  79. File: emacs,  Node: Fortran Abbrev,  Prev: Fortran Columns,  Up: Fortran
  80.  
  81. Fortran Keyword Abbrevs
  82. -----------------------
  83.  
  84.    Fortran mode provides many built-in abbrevs for common keywords and
  85. declarations.  These are the same sort of abbrev that you can define
  86. yourself.  To use them, you must turn on Abbrev mode.  *Note Abbrevs::.
  87.  
  88.    The built-in abbrevs are unusual in one way: they all start with a
  89. semicolon.  You cannot normally use semicolon in an abbrev, but Fortran
  90. mode makes this possible by changing the syntax of semicolon to "word
  91. constituent."
  92.  
  93.    For example, one built-in Fortran abbrev is `;c' for `continue'.  If
  94. you insert `;c' and then insert a punctuation character such as a space
  95. or a newline, the `;c' expands automatically to `continue', provided
  96. Abbrev mode is enabled.
  97.  
  98.    Type `;?' or `;C-h' to display a list of all the built-in Fortran
  99. abbrevs and what they stand for.
  100.  
  101. 
  102. File: emacs,  Node: Asm Mode,  Prev: Fortran,  Up: Programs
  103.  
  104. Asm Mode
  105. ========
  106.  
  107.    Asm mode is a major mode for editing files of assembler code.  It
  108. defines these commands:
  109.  
  110. `TAB'
  111.      `tab-to-tab-stop'.
  112.  
  113. `LFD'
  114.      Insert a newline and then indent using `tab-to-tab-stop'.
  115.  
  116. `:'
  117.      Insert a colon and then remove the indentation from before the
  118.      label preceding colon.  Then do `tab-to-tab-stop'.
  119.  
  120. `;'
  121.      Insert or align a comment.
  122.  
  123.    The variable `asm-comment-char' specifies which character starts
  124. comments in assembler syntax.
  125.  
  126. 
  127. File: emacs,  Node: Building,  Next: Abbrevs,  Prev: Programs,  Up: Top
  128.  
  129. Compiling and Testing Programs
  130. ******************************
  131.  
  132.    The previous chapter discusses the Emacs commands that are useful for
  133. making changes in programs.  This chapter deals with commands that
  134. assist in the larger process of developing and maintaining programs.
  135.  
  136. * Menu:
  137.  
  138. * Compilation::                   Compiling programs in languages other
  139.                                     than Lisp (C, Pascal, etc.)
  140. * Debuggers::                      Running symbolic debuggers for
  141.                                     non-Lisp programs.
  142. * Executing Lisp::                Various modes for editing Lisp programs,
  143.                                     with different facilities for running
  144.                                     the Lisp programs.
  145. * Libraries: Lisp Libraries.      Creating Lisp programs to run in Emacs.
  146. * Interaction: Lisp Interaction.  Executing Lisp in an Emacs buffer.
  147. * Eval: Lisp Eval.                Executing a single Lisp expression in Emacs.
  148. * External Lisp::                 Communicating through Emacs with a
  149.                                     separate Lisp.
  150.  
  151. 
  152. File: emacs,  Node: Compilation,  Next: Debuggers,  Up: Building
  153.  
  154. Running Compilations under Emacs
  155. ================================
  156.  
  157.    Emacs can run compilers for noninteractive languages such as C and
  158. Fortran as inferior processes, feeding the error log into an Emacs
  159. buffer.  It can also parse the error messages and show you the source
  160. lines where compilation errors occurred.
  161.  
  162. `M-x compile'
  163.      Run a compiler asynchronously under Emacs, with error messages to
  164.      `*compilation*' buffer.
  165.  
  166. `M-x grep'
  167.      Run `grep' asynchronously under Emacs, with matching lines listed
  168.      in the buffer named `*grep*'.
  169.  
  170. `M-x kill-compilation'
  171. `M-x kill-grep'
  172.      Kill the running compilation or `grep' subprocess.
  173.  
  174. `C-x `'
  175.      Visit the locus of the next compiler error message or `grep' match.
  176.  
  177. `RET'
  178.      Visit the locus of the error message that point is on.  This
  179.      command is used in the compilation buffer.
  180.  
  181. `Mouse-2'
  182.      Visit the locus of the error message that you click on.
  183.  
  184.    To run `make' or another compilation command, do `M-x compile'.
  185. This command reads a shell command line using the minibuffer, and then
  186. executes the command in an inferior shell, putting output in the buffer
  187. named `*compilation*'.  The current buffer's default directory is used
  188. as the working directory for the execution of the command; normally,
  189. therefore, the compilation happens in this directory.
  190.  
  191.    When the shell command line is read, the minibuffer appears
  192. containing a default command line, which is the command you used the
  193. last time you did `M-x compile'.  If you type just RET, the same command
  194. line is used again.  For the first `M-x compile', the default is `make
  195. -k'.  The default compilation command comes from the variable
  196. `compile-command'; if the appropriate compilation command for a file is
  197. something other than `make -k', it can be useful for the file to
  198. specify a local value for `compile-command' (*note File Variables::.).
  199.  
  200.    Starting a compilation displays the buffer `*compilation*' in
  201. another window but does not select it.  The buffer's mode line tells you
  202. whether compilation is finished, with the word `run' or `exit' inside
  203. the parentheses.  You do not have to keep this buffer visible;
  204. compilation continues in any case.  While a compilation is going on, the
  205. string `Compiling' appears in the mode lines of all windows.  When this
  206. string disappears, the compilation is finished.
  207.  
  208.    If you want to watch the compilation transcript as it appears, switch
  209. to the `*compilation*' buffer and move point to the end of the buffer.
  210. When point is at the end, new compilation output is inserted above
  211. point, which remains at the end.  If point is not at the end of the
  212. buffer, it remains fixed while more compilation output is added at the
  213. end of the buffer.
  214.  
  215.    To kill the compilation process, do `M-x kill-compilation'.  When
  216. the compiler process terminates, the mode line of the `*compilation*'
  217. buffer changes to say `signal' instead of `run'.  Starting a new
  218. compilation also kills any running compilation, as only one can exist
  219. at any time.  However, `M-x compile' asks for confirmation before
  220. actually killing a compilation that is running.
  221.  
  222.    The `*compilation*' buffer uses a special major mode, Compilation
  223. mode.  This mode provides the keys SPC and DEL to scroll by screenfuls,
  224. and `M-n' and `M-p' to move to the next or previous error message.  You
  225. can also use `M-{' and `M-}' to move up or down to an error message for
  226. a different source file.
  227.  
  228.    You can visit the source for any particular error message by moving
  229. point in `*compilation*' to that error message and typing RET
  230. (`compile-goto-error').  Or click `Mouse-2' on the error message; you
  231. need not switch to the `*compilation*' buffer first.
  232.  
  233.    To parse the compiler error messages sequentially, type `C-x `'
  234. (`next-error').  The character following the `C-x' is the backquote or
  235. "grave accent," not the single-quote.  This command is available in all
  236. buffers, not just in `*compilation*'; it displays the next error
  237. message at the top of one window and source location of the error in
  238. another window.
  239.  
  240.    The first time `C-x `' is used after the start of a compilation, it
  241. moves to the first error's location.  Subsequent uses of `C-x `'
  242. advance down to subsequent errors.  If you visit a specific error
  243. message with RET or `Mouse-2', subsequent `C-x `' commands advance from
  244. there.  When `C-x `' gets to the end of the buffer and finds no more
  245. error messages to visit, it fails and signals an Emacs error.
  246.  
  247.    `C-u C-x `' starts scanning from the beginning of the compilation
  248. buffer.  This way, you can process the same set of errors again.
  249.  
  250.    Just as you can run a compiler, you can also run `grep' and then
  251. visit the lines on which matches were found.  To do this, type `M-x
  252. grep' with an argument line that contains the same arguments you would
  253. give `grep' when running it normally: a `grep'-style regexp (usually in
  254. single-quotes to quote the shell's special characters) followed by file
  255. names which may use wildcards.  The output from `grep' goes in the
  256. `*grep*' buffer, and you can find the matching lines in the source with
  257. `C-x `' and RET just like compiler errors.
  258.  
  259.    Note: a shell is used to run the compile command, but the shell is
  260. told that it should be noninteractive.  This means in particular that
  261. the shell starts up with no prompt.  If you find your usual shell prompt
  262. making an unsightly appearance in the `*compilation*' buffer, it means
  263. you have made a mistake in your shell's init file by setting the prompt
  264. unconditionally.  (The init file name may be `.profile', `.cshrc',
  265. `.shrc', or various other things, depending on the shell you use.)  The
  266. shell init file should set the prompt only if there already is a
  267. prompt.  In csh, here is how to do it:
  268.  
  269.      if ($?prompt) set prompt = ...
  270.  
  271. And here's how to do it in bash:
  272.  
  273.      if [ "${PS1+set}" = set ]
  274.      then prompt=...
  275.      fi
  276.  
  277.    There may well be other things that your shell's init file ought to
  278. do only for an interactive shell.  You can use the same method to
  279. conditionalize them.
  280.  
  281.    The features of Compilation mode are also available in a minor mode
  282. called Compilation Minor mode.  This lets you parse error messages in
  283. any buffer, not just a normal compilation output buffer.  Type `M-x
  284. compilation-minor-mode' to enable the minor mode.  This defines the keys
  285. RET and `Mouse-2', as in the Compilation major mode.  In an Rlogin
  286. buffer (*note Remote Host::.), Compilation minor mode automatically
  287. accesses remote source files by FTP (*note File Names::.).
  288.  
  289.    The MS-DOS "operating system" does not support asynchronous
  290. subprocesses; to work around this lack, `M-x compile' runs the
  291. compilation command synchronously on MS-DOS.  As a consequence, you must
  292. wait until the command finishes before you can do anything else in
  293. Emacs.  *Note MS-DOS::.
  294.  
  295. 
  296. File: emacs,  Node: Debuggers,  Next: Executing Lisp,  Prev: Compilation,  Up: Building
  297.  
  298. Running Debuggers Under Emacs
  299. =============================
  300.  
  301.    The GUD (Grand Unified Debugger) library provides an interface to
  302. various symbolic debuggers from within Emacs.  We recommend the debugger
  303. GDB, which is free software, but you can also run DBX, SDB or XDB if you
  304. have them.  GUD can also serve as an interface to the Perl's debugging
  305. mode.
  306.  
  307. * Menu:
  308.  
  309. * Starting GUD::    How to start a debugger subprocess.
  310. * Debugger Operation::    Connection between the debugger and source buffers.
  311. * Commands of GUD::    Key bindings for common commands.
  312. * GUD Customization::    Defining your own commands for GUD.
  313.  
  314. 
  315. File: emacs,  Node: Starting GUD,  Next: Debugger Operation,  Up: Debuggers
  316.  
  317. Starting GUD
  318. ------------
  319.  
  320.    There are five commands for starting a debugger, each corresponding
  321. to a particular debugger program.
  322.  
  323. `M-x gdb RET FILE RET'
  324.      Run GDB as a subprocess of Emacs.  This command creates a buffer
  325.      for input and output to GDB, and switches to it.  If a GDB buffer
  326.      already exists, it just switches to that buffer.
  327.  
  328. `M-x dbx RET FILE RET'
  329.      Similar, but run DBX instead of GDB.
  330.  
  331. `M-x xdb RET FILE RET'
  332.      Similar, but run XDB instead of GDB.  Use the variable
  333.      `gud-xdb-directories' to specify directories to search for source
  334.      files.
  335.  
  336. `M-x sdb RET FILE RET'
  337.      Similar, but run SDB instead of GDB.
  338.  
  339.      Some versions of SDB do not mention source file names in their
  340.      messages.  When you use them, you need to have a valid tags table
  341.      (*note Tags::.) in order for GUD to find functions in the source
  342.      code.  If you have not visited a tags table or the tags table
  343.      doesn't list one of the functions, you get a message saying `The
  344.      sdb support requires a valid tags table to work'.  If this
  345.      happens, generate a valid tags table in the working directory and
  346.      try again.
  347.  
  348. `M-x perldb RET FILE RET'
  349.      Run the Perl interpreter in debug mode to debug FILE, a Perl
  350.      program.
  351.  
  352.    You can only run one debugger process at a time.
  353.  
  354.    Each of these commands takes one argument: a command line to invoke
  355. the debugger.  In the simplest case, specify just the name of the
  356. executable file you want to debug.  You may also use options that the
  357. debugger supports.  However, shell wild cards and variables are not
  358. allowed.  GUD assumes that the first argument not preceded by a `-' is
  359. the executable file name.
  360.  
  361. 
  362. File: emacs,  Node: Debugger Operation,  Next: Commands of GUD,  Prev: Starting GUD,  Up: Debuggers
  363.  
  364. Debugger Operation
  365. ------------------
  366.  
  367.    When you run a debugger with GUD, the debugger uses an Emacs buffer
  368. for its ordinary input and output.  This is called the GUD buffer.  The
  369. debugger displays the source files of the program by visiting them in
  370. Emacs buffers.  An arrow (`=>') in one of these buffers indicates the
  371. current execution line.  Moving point in this buffer does not move the
  372. arrow.
  373.  
  374.    You can start editing these source files at any time in the buffers
  375. that were made to display them.  The arrow is not part of the file's
  376. text; it appears only on the screen.  If you do modify a source file,
  377. keep in mind that inserting or deleting lines will throw off the arrow's
  378. positioning; GUD has no way of figuring out which line corresponded
  379. before your changes to the line number in a debugger message.  Also,
  380. you'll typically have to recompile and restart the program for your
  381. changes to be reflected in the debugger's tables.
  382.  
  383.    If you wish, you can control your debugger process entirely through
  384. the debugger buffer, which uses a variant of Shell mode.  All the usual
  385. commands for your debugger are available, and you can use the Shell mode
  386. history commands to repeat them.  *Note Shell Mode::.
  387.  
  388. 
  389. File: emacs,  Node: Commands of GUD,  Next: GUD Customization,  Prev: Debugger Operation,  Up: Debuggers
  390.  
  391. Commands of GUD
  392. ---------------
  393.  
  394.    The GUD interaction buffer uses a variant of Shell mode, so the
  395. commands of Shell mode are available (*note Shell Mode::.).  GUD mode
  396. also provides commands for setting and clearing breakpoints, for
  397. selecting stack frames, and for stepping through the program.  These
  398. commands are available both in the GUD buffer and globally, but with
  399. different key bindings.
  400.  
  401.    The breakpoint commands are usually used in source file buffers,
  402. because that is the way to specify where to set or clear the breakpoint.
  403. Here's the global command to set a breakpoint:
  404.  
  405. `C-x SPC'
  406.      Set a breakpoint on the source line that point is on.
  407.  
  408.    Here are the other special commands provided by GUD.  The keys
  409. starting with `C-c' are available only in the GUD interaction buffer.
  410. The bindings that start with `C-x C-a' are available in the GUD buffer
  411. and also in source files.
  412.  
  413. `C-c C-l'
  414. `C-x C-a C-l'
  415.      Display in another window the last line referred to in the GUD
  416.      buffer (that is, the line indicated in the last location message).
  417.      This runs the command `gud-refresh'.
  418.  
  419. `C-c C-s'
  420. `C-x C-a C-s'
  421.      Execute a single line of code (`gud-step').  If the line contains
  422.      a function call, execution stops after entering the called
  423.      function.
  424.  
  425. `C-c C-n'
  426. `C-x C-a C-n'
  427.      Execute a single line of code, stepping across entire function
  428.      calls at full speed (`gud-next').
  429.  
  430. `C-c C-i'
  431. `C-x C-a C-i'
  432.      Execute a single machine instruction (`gud-stepi').
  433.  
  434. `C-c C-r'
  435. `C-x C-a C-r'
  436.      Continue execution without specifying any stopping point.  The
  437.      program will run until it hits a breakpoint, terminates, or gets a
  438.      signal that the debugger is checking for (`gud-cont').
  439.  
  440. `C-c C-d'
  441. `C-x C-a C-d'
  442.      Delete the breakpoint(s) on the current source line, if any
  443.      (`gud-remove').  If you use this command in the GUD interaction
  444.      buffer, it applies to the line where the program last stopped.
  445.  
  446. `C-c C-t'
  447. `C-x C-a C-t'
  448.      Set a temporary breakpoint on the current source line, if any.  If
  449.      you use this command in the GUD interaction buffer, it applies to
  450.      the line where the program last stopped.
  451.  
  452.    The above commands are common to all supported debuggers.  If you are
  453. using GDB or (some versions of) DBX, these additional commands are
  454. available:
  455.  
  456. `C-c <'
  457. `C-x C-a <'
  458.      Select the next enclosing stack frame (`gud-up').  This is
  459.      equivalent to the `up' command.
  460.  
  461. `C-c >'
  462. `C-x C-a >'
  463.      Select the next inner stack frame (`gud-down').  This is
  464.      equivalent to the `down' command.
  465.  
  466.    If you are using GDB, these additional key bindings are available:
  467.  
  468. `TAB'
  469.      With GDB, complete a symbol name (`gud-gdb-complete-command').
  470.      This key is available only in the GUD interaction buffer, and
  471.      requires GDB versions 4.13 and later.
  472.  
  473. `C-c C-f'
  474. `C-x C-a C-f'
  475.      Run the program until the selected stack frame returns (or until it
  476.      stops for some other reason).
  477.  
  478.    These commands interpret a numeric argument as a repeat count, when
  479. that makes sense.
  480.  
  481.    Because TAB serves as a completion command, you can't use it to
  482. enter a tab as input to the program you are debugging with GDB.
  483. Instead, type `C-q TAB' to enter a tab.
  484.  
  485. 
  486. File: emacs,  Node: GUD Customization,  Prev: Commands of GUD,  Up: Debuggers
  487.  
  488. GUD Customization
  489. -----------------
  490.  
  491.    On startup, GUD runs one of the following hooks: `gdb-mode-hook', if
  492. you are using GDB; `dbx-mode-hook', if you are using DBX;
  493. `sdb-mode-hook', if you are using SDB; `xdb-mode-hook', if you are
  494. using XDB; `perldb-mode-hook', for Perl debugging mode.  You can use
  495. these hooks to define custom key bindings for the debugger interaction
  496. buffer.  *Note Hooks::.
  497.  
  498.    Here is a convenient way to define a command that sends a particular
  499. command string to the debugger, and set up a key binding for it in the
  500. debugger interaction buffer:
  501.  
  502.      (gud-def FUNCTION CMDSTRING BINDING DOCSTRING)
  503.  
  504.    This defines a command named FUNCTION which sends CMDSTRING to the
  505. debugger process, and gives it the documentation string DOCSTRING.  You
  506. can use the command thus defined in any buffer.  If BINDING is
  507. non-`nil', `gud-def' also binds the command to `C-c BINDING' in the GUD
  508. buffer's mode and to `C-x C-a BINDING' generally.
  509.  
  510.    The command string CMDSTRING may contain certain `%'-sequences that
  511. stand for data to be filled in at the time FUNCTION is called:
  512.  
  513. `%f'
  514.      The name of the current source file.  If the current buffer is the
  515.      GUD buffer, then the "current source file" is the file that the
  516.      program stopped in.
  517.  
  518. `%l'
  519.      The number of the current source line.  If the current buffer is
  520.      the GUD buffer, then the "current source line" is the line that
  521.      the program stopped in.
  522.  
  523. `%e'
  524.      The text of the C lvalue or function-call expression at or
  525.      adjacent to point.
  526.  
  527. `%a'
  528.      The text of the hexadecimal address at or adjacent to point.
  529.  
  530. `%p'
  531.      The numeric argument of the called function, as a decimal number.
  532.      If the command is used without a numeric argument, `%p' stands for
  533.      the empty string.
  534.  
  535.      If you don't use `%p' in the command string, the command you define
  536.      ignores any numeric argument.
  537.  
  538. 
  539. File: emacs,  Node: Executing Lisp,  Next: Lisp Libraries,  Prev: Debuggers,  Up: Building
  540.  
  541. Executing Lisp Expressions
  542. ==========================
  543.  
  544.    Emacs has several different major modes for Lisp and Scheme.  They
  545. are the same in terms of editing commands, but differ in the commands
  546. for executing Lisp expressions.  Each mode has its own purpose.
  547.  
  548. Emacs-Lisp mode
  549.      The mode for editing source files of programs to run in Emacs Lisp.
  550.      This mode defines `C-M-x' to evaluate the current defun.  *Note
  551.      Lisp Libraries::.
  552.  
  553. Lisp Interaction mode
  554.      The mode for an interactive session with Emacs Lisp.  It defines
  555.      LFD to evaluate the sexp before point and insert its value in the
  556.      buffer.  *Note Lisp Interaction::.
  557.  
  558. Lisp mode
  559.      The mode for editing source files of programs that run in Lisps
  560.      other than Emacs Lisp.  This mode defines `C-M-x' to send the
  561.      current defun to an inferior Lisp process.  *Note External Lisp::.
  562.  
  563. Inferior Lisp mode
  564.      The mode for an interactive session with an inferior Lisp process.
  565.      This mode combines the special features of Lisp mode and Shell mode
  566.      (*note Shell Mode::.).
  567.  
  568. Scheme mode
  569.      Like Lisp mode but for Scheme programs.
  570.  
  571. Inferior Scheme mode
  572.      The mode for an interactive session with an inferior Scheme
  573.      process.
  574.  
  575.    Most editing commands for working with Lisp programs are in fact
  576. available globally.  *Note Programs::.
  577.  
  578. 
  579. File: emacs,  Node: Lisp Libraries,  Next: Lisp Interaction,  Prev: Executing Lisp,  Up: Building
  580.  
  581. Libraries of Lisp Code for Emacs
  582. ================================
  583.  
  584.    Lisp code for Emacs editing commands is stored in files whose names
  585. conventionally end in `.el'.  This ending tells Emacs to edit them in
  586. Emacs-Lisp mode (*note Executing Lisp::.).
  587.  
  588.    To execute a file of Emacs Lisp code, use `M-x load-file'.  This
  589. command reads a file name using the minibuffer and then executes the
  590. contents of that file as Lisp code.  It is not necessary to visit the
  591. file first; in any case, this command reads the file as found on disk,
  592. not text in an Emacs buffer.
  593.  
  594.    Once a file of Lisp code is installed in the Emacs Lisp library
  595. directories, users can load it using `M-x load-library'.  Programs can
  596. load it by calling `load-library', or with `load', a more primitive
  597. function that is similar but accepts some additional arguments.
  598.  
  599.    `M-x load-library' differs from `M-x load-file' in that it searches
  600. a sequence of directories and tries three file names in each directory.
  601. Suppose your argument is LIB; the three names are `LIB.elc', `LIB.el',
  602. and lastly just `LIB'.  If `LIB.elc' exists, it is by convention the
  603. result of compiling `LIB.el'; it is better to load the compiled file,
  604. since it will load and run faster.
  605.  
  606.    If `load-library' finds that `LIB.el' is newer than `LIB.elc' file,
  607. it prints a warning, because it's likely that somebody made changes to
  608. the `.el' file and forgot to recompile it.
  609.  
  610.    Because the argument to `load-library' is usually not in itself a
  611. valid file name, file name completion is not available.  Indeed, when
  612. using this command, you usually do not know exactly what file name will
  613. be used.
  614.  
  615.    The sequence of directories searched by `M-x load-library' is
  616. specified by the variable `load-path', a list of strings that are
  617. directory names.  The default value of the list contains the directory
  618. where the Lisp code for Emacs itself is stored.  If you have libraries
  619. of your own, put them in a single directory and add that directory to
  620. `load-path'.  `nil' in this list stands for the current default
  621. directory, but it is probably not a good idea to put `nil' in the list.
  622. If you find yourself wishing that `nil' were in the list, most likely
  623. what you really want to do is use `M-x load-file' this once.
  624.  
  625.    Often you do not have to give any command to load a library, because
  626. the commands defined in the library are set up to "autoload" that
  627. library.  Trying to run any of those commands calls `load' to load the
  628. library; this replaces the autoload definitions with the real ones from
  629. the library.
  630.  
  631.    Emacs Lisp code can be compiled into byte-code which loads faster,
  632. takes up less space when loaded, and executes faster.  *Note Byte
  633. Compilation: (elisp)Byte Compilation.  By convention, the compiled code
  634. for a library goes in a separate file whose name consists of the
  635. library source file with `c' appended.  Thus, the compiled code for
  636. `foo.el' goes in `foo.elc'.  That's why `load-library' searches for
  637. `.elc' files first.
  638.  
  639. 
  640. File: emacs,  Node: Lisp Eval,  Next: External Lisp,  Prev: Lisp Interaction,  Up: Building
  641.  
  642. Evaluating Emacs-Lisp Expressions
  643. =================================
  644.  
  645.    Lisp programs intended to be run in Emacs should be edited in
  646. Emacs-Lisp mode; this happens automatically for file names ending in
  647. `.el'.  By contrast, Lisp mode itself is used for editing Lisp programs
  648. intended for other Lisp systems.  To switch to Emacs-Lisp mode
  649. explicitly, use the command `M-x emacs-lisp-mode'.
  650.  
  651.    For testing of Lisp programs to run in Emacs, it is often useful to
  652. evaluate part of the program as it is found in the Emacs buffer.  For
  653. example, after changing the text of a Lisp function definition,
  654. evaluating the definition installs the change for future calls to the
  655. function.  Evaluation of Lisp expressions is also useful in any kind of
  656. editing, for invoking noninteractive functions (functions that are not
  657. commands).
  658.  
  659. `M-:'
  660.      Read a single Lisp expression in the minibuffer, evaluate it, and
  661.      print the value in the echo area (`eval-expression').
  662.  
  663. `C-x C-e'
  664.      Evaluate the Lisp expression before point, and print the value in
  665.      the echo area (`eval-last-sexp').
  666.  
  667. `C-M-x'
  668.      Evaluate the defun containing or after point, and print the value
  669.      in the echo area (`eval-defun').
  670.  
  671. `M-x eval-region'
  672.      Evaluate all the Lisp expressions in the region.
  673.  
  674. `M-x eval-current-buffer'
  675.      Evaluate all the Lisp expressions in the buffer.
  676.  
  677.    `M-:' (`eval-expression') is the most basic command for evaluating a
  678. Lisp expression interactively.  It reads the expression using the
  679. minibuffer, so you can execute any expression on a buffer regardless of
  680. what the buffer contains.  When the expression is evaluated, the current
  681. buffer is once again the buffer that was current when `M-:' was typed.
  682.  
  683.    `M-:' can easily confuse users who do not understand it.  Therefore,
  684. `eval-expression' is normally a disabled command.  Attempting to use
  685. this command asks for confirmation and gives you the option of enabling
  686. it; once you enable the command, confirmation will no longer be
  687. required for it.  *Note Disabling::.
  688.  
  689.    In Emacs-Lisp mode, the key `C-M-x' is bound to the command
  690. `eval-defun', which parses the defun containing or following point as a
  691. Lisp expression and evaluates it.  The value is printed in the echo
  692. area.  This command is convenient for installing in the Lisp environment
  693. changes that you have just made in the text of a function definition.
  694.  
  695.    `C-M-x' treats `defvar' expressions specially.  Normally, evaluating
  696. a `defvar' expression does nothing if the variable it defines already
  697. has a value.  But `C-M-x' unconditionally resets the variable to the
  698. initial value specified in the `defvar' expression.  This special
  699. feature is convenient for debugging Lisp programs.
  700.  
  701.    The command `C-x C-e' (`eval-last-sexp') evaluates the Lisp
  702. expression preceding point in the buffer, and displays the value in the
  703. echo area.  It is available in all major modes, not just Emacs-Lisp
  704. mode.  It does not treat `defvar' specially.
  705.  
  706.    If `C-M-x' or `C-x C-e' is given a numeric argument, it inserts the
  707. value into the current buffer at point, rather than displaying it in
  708. the echo area.  The argument's value does not matter.
  709.  
  710.    The most general command for evaluating Lisp expressions from a
  711. buffer is `eval-region'.  `M-x eval-region' parses the text of the
  712. region as one or more Lisp expressions, evaluating them one by one.
  713. `M-x eval-current-buffer' is similar but evaluates the entire buffer.
  714. This is a reasonable way to install the contents of a file of Lisp code
  715. that you are just ready to test.  Later, as you find bugs and change
  716. individual functions, use `C-M-x' on each function that you change.
  717. This keeps the Lisp world in step with the source file.
  718.  
  719. 
  720. File: emacs,  Node: Lisp Interaction,  Next: Lisp Eval,  Prev: Lisp Libraries,  Up: Building
  721.  
  722. Lisp Interaction Buffers
  723. ========================
  724.  
  725.    The buffer `*scratch*' which is selected when Emacs starts up is
  726. provided for evaluating Lisp expressions interactively inside Emacs.
  727.  
  728.    The simplest way to use the `*scratch*' buffer is to insert Lisp
  729. expressions and type LFD after each expression.  This command reads the
  730. Lisp expression before point, evaluates it, and inserts the value in
  731. printed representation before point.  The result is a complete
  732. typescript of the expressions you have evaluated and their values.
  733.  
  734.    The `*scratch*' buffer's major mode is Lisp Interaction mode, which
  735. is the same as Emacs-Lisp mode except for the binding of LFD.
  736.  
  737.    The rationale for this feature is that Emacs must have a buffer when
  738. it starts up, but that buffer is not useful for editing files since a
  739. new buffer is made for every file that you visit.  The Lisp interpreter
  740. typescript is the most useful thing I can think of for the initial
  741. buffer to do.  Type `M-x lisp-interaction-mode' to put the current
  742. buffer in Lisp Interaction mode.
  743.  
  744.    An alternative way of evaluating Emacs Lisp expressions interactively
  745. is to use Inferior Emacs-Lisp mode, which provides an interface rather
  746. like Shell mode (*note Shell Mode::.) for evaluating Emacs Lisp
  747. expressions.  Type `M-x ielm' to create an `*ielm*' buffer which uses
  748. this mode.
  749.  
  750. 
  751. File: emacs,  Node: External Lisp,  Prev: Lisp Eval,  Up: Building
  752.  
  753. Running an External Lisp
  754. ========================
  755.  
  756.    Emacs has facilities for running programs in other Lisp systems.
  757. You can run a Lisp process as an inferior of Emacs, and pass
  758. expressions to it to be evaluated.  You can also pass changed function
  759. definitions directly from the Emacs buffers in which you edit the Lisp
  760. programs to the inferior Lisp process.
  761.  
  762.    To run an inferior Lisp process, type `M-x run-lisp'.  This runs the
  763. program named `lisp', the same program you would run by typing `lisp'
  764. as a shell command, with both input and output going through an Emacs
  765. buffer named `*lisp*'.  That is to say, any "terminal output" from Lisp
  766. will go into the buffer, advancing point, and any "terminal input" for
  767. Lisp comes from text in the buffer.  (You can change the name of the
  768. Lisp executable file by setting the variable `inferior-lisp-program'.)
  769.  
  770.    To give input to Lisp, go to the end of the buffer and type the
  771. input, terminated by RET.  The `*lisp*' buffer is in Inferior Lisp
  772. mode, which combines the special characteristics of Lisp mode with most
  773. of the features of Shell mode (*note Shell Mode::.).  The definition of
  774. RET to send a line to a subprocess is one of the features of Shell mode.
  775.  
  776.    For the source files of programs to run in external Lisps, use Lisp
  777. mode.  This mode can be selected with `M-x lisp-mode', and is used
  778. automatically for files whose names end in `.l', `.lsp', or `.lisp', as
  779. most Lisp systems usually expect.
  780.  
  781.    When you edit a function in a Lisp program you are running, the
  782. easiest way to send the changed definition to the inferior Lisp process
  783. is the key `C-M-x'.  In Lisp mode, this runs the function
  784. `lisp-eval-defun', which finds the defun around or following point and
  785. sends it as input to the Lisp process.  (Emacs can send input to any
  786. inferior process regardless of what buffer is current.)
  787.  
  788.    Contrast the meanings of `C-M-x' in Lisp mode (for editing programs
  789. to be run in another Lisp system) and Emacs-Lisp mode (for editing Lisp
  790. programs to be run in Emacs): in both modes it has the effect of
  791. installing the function definition that point is in, but the way of
  792. doing so is different according to where the relevant Lisp environment
  793. is found.  *Note Executing Lisp::.
  794.  
  795. 
  796. File: emacs,  Node: Abbrevs,  Next: Picture,  Prev: Building,  Up: Top
  797.  
  798. Abbrevs
  799. *******
  800.  
  801.    A defined "abbrev" is a word which "expands", if you insert it, into
  802. some different text.  Abbrevs are defined by the user to expand in
  803. specific ways.  For example, you might define `foo' as an abbrev
  804. expanding to `find outer otter'.  Then you would be able to insert
  805. `find outer otter ' into the buffer by typing `f o o SPC'.
  806.  
  807.    A second kind of abbreviation facility is called "dynamic abbrev
  808. expansion".  You use dynamic abbrev expansion with an explicit command
  809. to expand the letters in the buffer before point by looking for other
  810. words in the buffer that start with those letters.  *Note Dynamic
  811. Abbrevs::.
  812.  
  813. * Menu:
  814.  
  815. * Abbrev Concepts::   Fundamentals of defined abbrevs.
  816. * Defining Abbrevs::  Defining an abbrev, so it will expand when typed.
  817. * Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion.
  818. * Editing Abbrevs::   Viewing or editing the entire list of defined abbrevs.
  819. * Saving Abbrevs::    Saving the entire list of abbrevs for another session.
  820. * Dynamic Abbrevs::   Abbreviations for words already in the buffer.
  821. * Dabbrev Customization:: What is a word, for dynamic abbrevs.  Case handling.
  822.  
  823. 
  824. File: emacs,  Node: Abbrev Concepts,  Next: Defining Abbrevs,  Up: Abbrevs
  825.  
  826. Abbrev Concepts
  827. ===============
  828.  
  829.    An "abbrev" is a word which has been defined to "expand" into a
  830. specified "expansion".  When you insert a word-separator character
  831. following the abbrev, that expands the abbrev--replacing the abbrev
  832. with its expansion.  For example, if `foo' is defined as an abbrev
  833. expanding to `find outer otter', then you can insert `find outer
  834. otter.'  into the buffer by typing `f o o .'.
  835.  
  836.    Abbrevs expand only when Abbrev mode (a minor mode) is enabled.
  837. Disabling Abbrev mode does not cause abbrev definitions to be forgotten,
  838. but they do not expand until Abbrev mode is enabled again.  The command
  839. `M-x abbrev-mode' toggles Abbrev mode; with a numeric argument, it
  840. turns Abbrev mode on if the argument is positive, off otherwise.  *Note
  841. Minor Modes::.  `abbrev-mode' is also a variable; Abbrev mode is on
  842. when the variable is non-`nil'.  The variable `abbrev-mode'
  843. automatically becomes local to the current buffer when it is set.
  844.  
  845.    Abbrev definitions can be "mode-specific"--active only in one major
  846. mode.  Abbrevs can also have "global" definitions that are active in
  847. all major modes.  The same abbrev can have a global definition and
  848. various mode-specific definitions for different major modes.  A mode
  849. specific definition for the current major mode overrides a global
  850. definition.
  851.  
  852.    Abbrevs can be defined interactively during the editing session.
  853. Lists of abbrev definitions can also be saved in files and reloaded in
  854. later sessions.  Some users keep extensive lists of abbrevs that they
  855. load in every session.
  856.  
  857. 
  858. File: emacs,  Node: Defining Abbrevs,  Next: Expanding Abbrevs,  Prev: Abbrev Concepts,  Up: Abbrevs
  859.  
  860. Defining Abbrevs
  861. ================
  862.  
  863. `C-x a g'
  864.      Define an abbrev, using one or more words before point as its
  865.      expansion (`add-global-abbrev').
  866.  
  867. `C-x a l'
  868.      Similar, but define an abbrev specific to the current major mode
  869.      (`add-mode-abbrev').
  870.  
  871. `C-x a i g'
  872.      Define a word in the buffer as an abbrev
  873.      (`inverse-add-global-abbrev').
  874.  
  875. `C-x a i l'
  876.      Define a word in the buffer as a mode-specific abbrev
  877.      (`inverse-add-mode-abbrev').
  878.  
  879. `M-x kill-all-abbrevs'
  880.      This command discards all abbrev definitions currently in effect,
  881.      leaving a blank slate.
  882.  
  883.    The usual way to define an abbrev is to enter the text you want the
  884. abbrev to expand to, position point after it, and type `C-x a g'
  885. (`add-global-abbrev').  This reads the abbrev itself using the
  886. minibuffer, and then defines it as an abbrev for one or more words
  887. before point.  Use a numeric argument to say how many words before
  888. point should be taken as the expansion.  For example, to define the
  889. abbrev `foo' as mentioned above, insert the text `find outer otter' and
  890. then type `C-u 3 C-x a g f o o RET'.
  891.  
  892.    An argument of zero to `C-x a g' means to use the contents of the
  893. region as the expansion of the abbrev being defined.
  894.  
  895.    The command `C-x a l' (`add-mode-abbrev') is similar, but defines a
  896. mode-specific abbrev.  Mode specific abbrevs are active only in a
  897. particular major mode.  `C-x a l' defines an abbrev for the major mode
  898. in effect at the time `C-x a l' is typed.  The arguments work the same
  899. as for `C-x a g'.
  900.  
  901.    If the text already in the buffer is the abbrev, rather than its
  902. expansion, use command `C-x a i g' (`inverse-add-global-abbrev')
  903. instead of `C-x a g', or use `C-x a i l' (`inverse-add-mode-abbrev')
  904. instead of `C-x a l'.  These commands are called "inverse" because they
  905. invert the meaning of the two text strings they use (one from the
  906. buffer and one read with the minibuffer).
  907.  
  908.    To change the definition of an abbrev, just define a new definition.
  909. When the abbrev has a prior definition, the abbrev definition commands
  910. ask for confirmation for replacing it.
  911.  
  912.    To remove an abbrev definition, give a negative argument to the
  913. abbrev definition command: `C-u - C-x a g' or `C-u - C-x a l'.  The
  914. former removes a global definition, while the latter removes a
  915. mode-specific definition.
  916.  
  917.    `M-x kill-all-abbrevs' removes all the abbrev definitions there are,
  918. both global and local.
  919.  
  920. 
  921. File: emacs,  Node: Expanding Abbrevs,  Next: Editing Abbrevs,  Prev: Defining Abbrevs,  Up: Abbrevs
  922.  
  923. Controlling Abbrev Expansion
  924. ============================
  925.  
  926.    An abbrev expands whenever it is present in the buffer just before
  927. point and you type a self-inserting whitespace or punctuation character
  928. (SPC, comma, etc.).  More precisely, any character that is not a word
  929. constituent expands an abbrev, and any word constituent character can
  930. be part of an abbrev.  The most common way to use an abbrev is to
  931. insert it and then insert a punctuation character to expand it.
  932.  
  933.    Abbrev expansion preserves case; thus, `foo' expands into `find
  934. outer otter'; `Foo' into `Find outer otter', and `FOO' into `FIND OUTER
  935. OTTER' or `Find Outer Otter' according to the variable
  936. `abbrev-all-caps' (a non-`nil' value chooses the first of the two
  937. expansions).
  938.  
  939.    These commands are used to control abbrev expansion:
  940.  
  941. `M-''
  942.      Separate a prefix from a following abbrev to be expanded
  943.      (`abbrev-prefix-mark').
  944.  
  945. `C-x a e'
  946.      Expand the abbrev before point (`expand-abbrev').  This is
  947.      effective even when Abbrev mode is not enabled.
  948.  
  949. `M-x expand-region-abbrevs'
  950.      Expand some or all abbrevs found in the region.
  951.  
  952.    You may wish to expand an abbrev with a prefix attached; for example,
  953. if `cnst' expands into `construction', you might want to use it to
  954. enter `reconstruction'.  It does not work to type `recnst', because
  955. that is not necessarily a defined abbrev.  What you can do is use the
  956. command `M-'' (`abbrev-prefix-mark') in between the prefix `re' and the
  957. abbrev `cnst'.  First, insert `re'.  Then type `M-''; this inserts a
  958. hyphen in the buffer to indicate that it has done its work.  Then
  959. insert the abbrev `cnst'; the buffer now contains `re-cnst'.  Now
  960. insert a non-word character to expand the abbrev `cnst' into
  961. `construction'.  This expansion step also deletes the hyphen that
  962. indicated `M-'' had been used.  The result is the desired
  963. `reconstruction'.
  964.  
  965.    If you actually want the text of the abbrev in the buffer, rather
  966. than its expansion, you can accomplish this by inserting the following
  967. punctuation with `C-q'.  Thus, `foo C-q ,' leaves `foo,' in the buffer.
  968.  
  969.    If you expand an abbrev by mistake, you can undo the expansion and
  970. bring back the abbrev itself by typing `C-_' to undo (*note Undo::.).
  971. This also undoes the insertion of the non-word character that expanded
  972. the abbrev.  If the result you want is the terminating non-word
  973. character plus the unexpanded abbrev, you must reinsert the terminating
  974. character, quoting it with `C-q'.
  975.  
  976.    `M-x expand-region-abbrevs' searches through the region for defined
  977. abbrevs, and for each one found offers to replace it with its expansion.
  978. This command is useful if you have typed in text using abbrevs but
  979. forgot to turn on Abbrev mode first.  It may also be useful together
  980. with a special set of abbrev definitions for making several global
  981. replacements at once.  This command is effective even if Abbrev mode is
  982. not enabled.
  983.  
  984.    Expanding an abbrev runs the hook `pre-abbrev-expand-hook' (*note
  985. Hooks::.).
  986.  
  987. 
  988. File: emacs,  Node: Editing Abbrevs,  Next: Saving Abbrevs,  Prev: Expanding Abbrevs,  Up: Abbrevs
  989.  
  990. Examining and Editing Abbrevs
  991. =============================
  992.  
  993. `M-x list-abbrevs'
  994.      Display a list of all abbrev definitions.
  995.  
  996. `M-x edit-abbrevs'
  997.      Edit a list of abbrevs; you can add, alter or remove definitions.
  998.  
  999.    The output from `M-x list-abbrevs' looks like this:
  1000.  
  1001.      (lisp-mode-abbrev-table)
  1002.      "dk"           0    "define-key"
  1003.      (global-abbrev-table)
  1004.      "dfn"           0    "definition"
  1005.  
  1006. (Some blank lines of no semantic significance, and some other abbrev
  1007. tables, have been omitted.)
  1008.  
  1009.    A line containing a name in parentheses is the header for abbrevs in
  1010. a particular abbrev table; `global-abbrev-table' contains all the global
  1011. abbrevs, and the other abbrev tables that are named after major modes
  1012. contain the mode-specific abbrevs.
  1013.  
  1014.    Within each abbrev table, each nonblank line defines one abbrev.  The
  1015. word at the beginning of the line is the abbrev.  The number that
  1016. follows is the number of times the abbrev has been expanded.  Emacs
  1017. keeps track of this to help you see which abbrevs you actually use, so
  1018. that you can eliminate those that you don't use often.  The string at
  1019. the end of the line is the expansion.
  1020.  
  1021.    `M-x edit-abbrevs' allows you to add, change or kill abbrev
  1022. definitions by editing a list of them in an Emacs buffer.  The list has
  1023. the same format described above.  The buffer of abbrevs is called
  1024. `*Abbrevs*', and is in Edit-Abbrevs mode.  Type `C-c C-c' in this
  1025. buffer to install the abbrev definitions as specified in the
  1026. buffer--and delete any abbrev definitions not listed.
  1027.  
  1028.    The command `edit-abbrevs' is actually the same as `list-abbrevs'
  1029. except that it selects the buffer `*Abbrevs*' whereas `list-abbrevs'
  1030. merely displays it in another window.
  1031.  
  1032. 
  1033. File: emacs,  Node: Saving Abbrevs,  Next: Dynamic Abbrevs,  Prev: Editing Abbrevs,  Up: Abbrevs
  1034.  
  1035. Saving Abbrevs
  1036. ==============
  1037.  
  1038.    These commands allow you to keep abbrev definitions between editing
  1039. sessions.
  1040.  
  1041. `M-x write-abbrev-file RET FILE RET'
  1042.      Write a file FILE describing all defined abbrevs.
  1043.  
  1044. `M-x read-abbrev-file RET FILE RET'
  1045.      Read the file FILE and define abbrevs as specified therein.
  1046.  
  1047. `M-x quietly-read-abbrev-file RET FILE RET'
  1048.      Similar but do not display a message about what is going on.
  1049.  
  1050. `M-x define-abbrevs'
  1051.      Define abbrevs from definitions in current buffer.
  1052.  
  1053. `M-x insert-abbrevs'
  1054.      Insert all abbrevs and their expansions into current buffer.
  1055.  
  1056.    `M-x write-abbrev-file' reads a file name using the minibuffer and
  1057. then writes a description of all current abbrev definitions into that
  1058. file.  This is used to save abbrev definitions for use in a later
  1059. session.  The text stored in the file is a series of Lisp expressions
  1060. that, when executed, define the same abbrevs that you currently have.
  1061.  
  1062.    `M-x read-abbrev-file' reads a file name using the minibuffer and
  1063. then reads the file, defining abbrevs according to the contents of the
  1064. file.  `M-x quietly-read-abbrev-file' is the same except that it does
  1065. not display a message in the echo area saying that it is doing its
  1066. work; it is actually useful primarily in the `.emacs' file.  If an
  1067. empty argument is given to either of these functions, they use the file
  1068. name specified in the variable `abbrev-file-name', which is by default
  1069. `"~/.abbrev_defs"'.
  1070.  
  1071.    Emacs will offer to save abbrevs automatically if you have changed
  1072. any of them, whenever it offers to save all files (for `C-x s' or `C-x
  1073. C-c').  This feature can be inhibited by setting the variable
  1074. `save-abbrevs' to `nil'.
  1075.  
  1076.    The commands `M-x insert-abbrevs' and `M-x define-abbrevs' are
  1077. similar to the previous commands but work on text in an Emacs buffer.
  1078. `M-x insert-abbrevs' inserts text into the current buffer before point,
  1079. describing all current abbrev definitions; `M-x define-abbrevs' parses
  1080. the entire current buffer and defines abbrevs accordingly.
  1081.  
  1082. 
  1083. File: emacs,  Node: Dynamic Abbrevs,  Next: Dabbrev Customization,  Prev: Saving Abbrevs,  Up: Abbrevs
  1084.  
  1085. Dynamic Abbrev Expansion
  1086. ========================
  1087.  
  1088.    The abbrev facility described above operates automatically as you
  1089. insert text, but all abbrevs must be defined explicitly.  By contrast,
  1090. "dynamic abbrevs" allow the meanings of abbrevs to be determined
  1091. automatically from the contents of the buffer, but dynamic abbrev
  1092. expansion happens only when you request it explicitly.
  1093.  
  1094. `M-/'
  1095.      Expand the word in the buffer before point as a "dynamic abbrev",
  1096.      by searching in the buffer for words starting with that
  1097.      abbreviation (`dabbrev-expand').
  1098.  
  1099. `C-M-/'
  1100.      Complete the word before point as a dynamic abbrev
  1101.      (`dabbrev-completion').
  1102.  
  1103.    For example, if the buffer contains `does this follow ' and you type
  1104. `f o M-/', the effect is to insert `follow' because that is the last
  1105. word in the buffer that starts with `fo'.  A numeric argument to `M-/'
  1106. says to take the second, third, etc. distinct expansion found looking
  1107. backward from point.  Repeating `M-/' searches for an alternative
  1108. expansion by looking farther back.  After considering the entire buffer
  1109. before point, it searches the text after point.  The variable
  1110. `dabbrev-limit', if non-`nil', specifies how far in the buffer to
  1111. search for an expansion.
  1112.  
  1113.    After searching all of the current buffer, `M-/' normally searches
  1114. other buffers, unless you have set `dabbrev-check-all-buffers' to `nil'.
  1115.  
  1116.    A negative argument to `M-/', as in `C-u - M-/', says to search
  1117. first for expansions after point, and second for expansions before
  1118. point.  If you repeat the `M-/' to look for another expansion, do not
  1119. specify an argument.  This tries all the expansions after point and
  1120. then the expansions before point.
  1121.  
  1122.    After you have expanded a dynamic abbrev, you can copy additional
  1123. words that follow the expansion in its original context.  Simply type
  1124. `SPC M-/' for each word you want to copy.  The spacing and punctuation
  1125. between words is copied along with the words.
  1126.  
  1127.    The command `C-M-/' (`dabbrev-completion') performs completion of a
  1128. dynamic abbreviation.  Instead of trying the possible expansions one by
  1129. one, it finds all of them, then inserts the text that they have in
  1130. common.  If they have nothing in common, `C-M-/' displays a list of
  1131. completions, from which you can select a choice in the usual manner.
  1132. *Note Completion::.
  1133.  
  1134.    Dynamic abbrev expansion is completely independent of Abbrev mode;
  1135. the expansion of a word with `M-/' is completely independent of whether
  1136. it has a definition as an ordinary abbrev.
  1137.  
  1138.